#coding=UTF-8
from flask_mail import Message
from app import mail
from threading import Thread
from flask import render_template

# 运行在后台的线程中
def send_async_email(app, msg):
    with app.app_context():
        mail.send(msg)
# recipients 收件人
# text_body 纯文本
# html_body html版本
def send_email(subject, sender, recipients, text_body, html_body):
    msg = Message(subject,sender = sender , recipients =recipients)
    msg.body = text_body
    msg.html = html_body
    Thread(target=send_async_email, args=(app,msg)).start()
